
package com.android.formula.task;

import android.content.Context;

import com.android.formula.common.MyApplication;
import com.android.formula.dao.FormulaNoteDao;
import com.android.formula.database.NoteDatabaseConnection;
import com.android.formula.model.FormulaNote;
import com.android.formula.model.TypeFormula;
import com.android.formula.utils.Constants;

/**
 * Get a Spot by Id
 */
public class GetNoteFormulaDBTask extends BaseDatabaseTask<TypeFormula, FormulaNote> {

    public GetNoteFormulaDBTask(Context context, TypeFormula param,
            IDataEventHandler<FormulaNote> dataEventHandler) {
        super(context, param, null, dataEventHandler);
    }

    @Override
    protected FormulaNote execute() {
        NoteDatabaseConnection sqlt = MyApplication.getDatabaseConnection();
        if (sqlt == null) {
            return null;
        }

        sqlt.open();
        FormulaNoteDao dao = new FormulaNoteDao(FormulaNote.class, mContext, sqlt.getDatabase());
        FormulaNote formulaNote = dao.getItem(Constants.TABLE_FOMULA_COL_TYPEID, ""
                + mRequestParams.getTypeId());
        sqlt.close();
        return formulaNote;
    }
}
